#include "Wire.h" // imports the wire library for talking over I2C #include int buttonPin = A1; // momentary push button on pin 0 int oldButtonVal = 0; #define NUM_PIXEL 64 #define PIN 9 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXEL, PIN, NEO_GRB + NEO_KHZ800); int nPatterns = 3; int lightPattern = 1; int out = 0 ; int w = 0 ; int sensorValue = 0; void setup() { Serial.begin(9600); //turn on serial monitor strip.begin(); clearStrip(); strip.show(); strip.setBrightness(15); testing(); pinMode(buttonPin, INPUT); digitalWrite(buttonPin, HIGH); // button pin is HIGH, so it drops to 0 if pressed } void testing(){ for(int L = 0; L<64; L++) { clearStrip(); strip.setPixelColor(L,wheel(((205+(L*3)) & 255)));//Gradient from blue (cold) to green (ok) to red (warm), first value here 205 = start color, second value here 42 = end color strip.show(); delay(100); } for(int L = 63; L>=0; L--) { clearStrip(); strip.setPixelColor(L,wheel(((205+(L*3)) & 255)));//Gradient from blue (cold) to green (ok) to red (warm), first value here 205 = start color, second value here 42 = end color strip.show(); delay(100); } } void dot() { sensorValue = analogRead(A0); int w = map(sensorValue, 0, 1023, 0, NUM_PIXEL); for(uint16_t L = 0; L nPatterns) lightPattern = 1; oldButtonVal = buttonVal; switch(lightPattern) { case 1: dot(); break; case 2: line(); break; } if (sensorValue > 150) {tone(11,1000); delay(50); noTone(11); } else {delay(50); } } //Color wheel ################################################################ uint32_t wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 205) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 205; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } } void clearStrip(){ for(int i = 0; i < NUM_PIXEL; i++) { strip.setPixelColor(i, 0); } }